package sangeng._02;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Demo01 {

    public static void main(String[] args) {
        
        //test1();
        
        //Integer integer = test2(1);
        //String string = test2("string");
        
        Integer[] arr1 = {2,3,1,45,24};
        Integer[] sortInteger = test3(arr1);
        print(sortInteger);

        String[] strArr = {"zz","haha","xx","hehe","xixi"};
        String[] strings = test3(strArr);
        print(strings);

        test4();
        
        test5(new ArrayList<>());
        
    }

    private static void test5(List<? extends Person> list) {
        
    }

    private static void test4() {
        List<Person> personList1 = new ArrayList<>();
        personList1.add(new Person("张三", 12, "男"));
        personList1.add(new Person("李四", 13, "男"));
        personList1.add(new Person("王五", 14, "男"));
        personList1.add(new Person("赵六", 15, "男"));

        List<Person> personList2 = new ArrayList<>();
        personList2.add(new Person("张三", 12, "男"));
        personList2.add(new Person("李四", 13, "男"));
        personList2.add(new Person("王五", 14, "男"));
        personList2.add(new Person("赵六", 15, "男"));

        List<Object> collect = personList1.stream().map(Person::getName).collect(Collectors.toList());
        
        collect.forEach(System.out::println);
    }

    // 对传进来的数组进行排序
    private static <T> T[] test3(T[] t){
        Arrays.sort(t);
        return t;
    }

    // 打印数组
    private static <T> void print(T[] arr) {
        for (T t : arr) {
            System.out.print(t+"\t");
        }
    }
    
    private static <T> T test2(T t){
        return t;
    }
    
    private static void test1() {
        List<String> list = new ArrayList<>();
        list.add("haha");
        list.add("hehe");
        String[] strings = list.toArray(new String[list.size()]);
        for (String string : strings) {
            System.out.println(string);
        }
    }
}
